# @Time:        2024/7/9 上午11:08
# @USER:        lihuizhuo
# @Site:        www.swust.edu.cn
# @File:        M
# @Software:    PyCharm
# @license:     Copyright(C), swust
# @Author:      huizhuo
# @Email:       huizhuoli@foxmail.com
# @Version:     V1.1.0
# @Time:        2024/7/7 上午10:48
# @USER:        lihuizhuo
# @Site:        www.swust.edu.cn
# @File:        M
# @Software:    PyCharm
# @license:     Copyright(C), swust
# @Author:      huizhuo
# @Email:       huizhuoli@foxmail.com
# @Version:     V1.1.0


import os
import sys
import pygame
from pygame import Surface
from pytmx import TiledObjectGroup

from scene.game_scene import TunnelSceneScene

parent_dir = os.path.dirname(
    os.path.dirname(os.path.abspath(__file__)))
print(parent_dir)
sys.path.insert(0, parent_dir)

# sys.path.insert(0, "/Users/lihuizhuo/PycharmProjects/2024-edu-prj/demo2")




def game_run():
    """
    游戏运行
    :return:
    """
    # pygame setup
    pygame.init()
    # set up the display 窗口
    screen = pygame.display.set_mode((1280, 720))
    clock = pygame.time.Clock()
    running = True
    scene = TunnelSceneScene()


    while running:
        # poll for events
        # pygame.QUIT event means the user clicked X to close your window
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False

        screen.blit(scene.get_current_surface(), (0, 0))
        scene.run()

        pygame.display.flip()

        clock.tick(20)  # limits FPS to 60

    pygame.quit()


if __name__ == '__main__': 
    game_run()
